import {defHttp} from '@/utils/http/axios';
import {
  roleListParams,
  rolePostParams,
  allocatedListParams,
  roleAuthUserCancelParams, roleAuthAllParams
} from "@/api/system/model/roleModel";

enum Api {
  roleList = '/system/role/list',
  systemRole = '/system/role',
  allocatedList = '/system/role/authUser/allocatedList',
  roleAuthUserCancel = '/system/role/authUser/cancel',
  roleAuthUserCancelAll = '/system/role/authUser/cancelAll',
  roleAuthUserSelectAll = '/system/role/authUser/selectAll',
  exportSystemRole = '/system/role/export'
}

//获取角色列表
export const getRoleList = (params: roleListParams) =>
  defHttp.get({url: Api.roleList,params}, {isTransformResponse: false})

//添加角色
export const addRole = (data: rolePostParams) =>
  defHttp.post({url: Api.systemRole}, {isTransformResponse: false})


//修改角色
export const updateRole = (data: rolePostParams) =>
  defHttp.put({url: Api.systemRole}, {isTransformResponse: false})


//删除角色
export const delRole = (id: Number) =>
  defHttp.delete({url: `${Api.systemRole}/${id}`}, {isTransformResponse: false})


//查询拥有该角色的用户列表
export const getAllocatedList = (params: allocatedListParams) =>
  defHttp.get({url: Api.allocatedList}, {isTransformResponse: false})


//取消用户的角色授权
export const roleAuthUserCancel = (data: roleAuthUserCancelParams) =>
  defHttp.put({url: Api.roleAuthUserCancel}, {isTransformResponse: false})

//批量取消用户的角色授权
export const roleAuthUserCancelAll = (params: roleAuthAllParams) =>
  defHttp.put({url: Api.roleAuthUserCancelAll}, {isTransformResponse: false})


//批量增加用户的角色授权
export const roleAuthUserSelectAll = (params: roleAuthAllParams) =>
  defHttp.put({url: Api.roleAuthUserSelectAll}, {isTransformResponse: false})






